function add_fav(arr, myarr,del) {

	 for (var arr2i = 0; arr2i < myarr.length; arr2i++) {
	   if (arr['id'] == myarr[arr2i]['id']) {
	     var news_sub = {
	      id:arr['id'],
	     }
	     if(!del) myarr.push(news_sub);
	     myarr.splice(arr2i, 1);
	     return [myarr,false];
	   }
	 }

	 if (myarr.length > 100) {
	   myarr.splice(0, 10);
	 }


	 myarr.push({
        id:arr['id']
      });
	 return [myarr,true];

	 }

function add_array(arr, myarr,del) {

  for (var arr2i = 0; arr2i < myarr.length; arr2i++) {
    if (arr['id'] == myarr[arr2i]['id']) {

      if(!del){
		  if('lc' in arr)
		  myarr.push({
        id:arr['id'],
       btime:arr['btime'],
	   lc:arr['lc'],
    title:arr['title'],
        img:arr['img']
       });
	   else
	   myarr.push({
	       id:arr['id'],
	      btime:arr['btime'],
	   title:arr['title'],
	       img:arr['img']
	      });
	   }
      myarr.splice(arr2i, 1);
      return [myarr,false];
    }
  }

  if (myarr.length > 100) {
    myarr.splice(0, 10);
  }

if('lc' in arr)
myarr.push({
    id:arr['id'],
    btime:arr['btime'],
	lc:arr['lc'],
    title:arr['title'],
     img:arr['img']
  });
else
  myarr.push({
    id:arr['id'],
    btime:arr['btime'],
    title:arr['title'],
     img:arr['img']
  });
  return [myarr,true];
}
module.exports ={
	add_fav:add_fav,
	add_array:add_array
	}